sysroot: Add a clearer error if /boot/loader isn't found
authorColin Walters <walters@verbum.org>
Mon, 26 Aug 2019 17:43:26 +0000 (17:43 +0000)
committerAtomic Bot <atomic-devel@projectatomic.io>
Mon, 26 Aug 2019 20:30:31 +0000 (20:30 +0000)
I've seen people confused by this error in the case where
`/boot` isn't mounted or the BLS fragments were deleted, etc.
If you understand ostree deeply it's clear but, let's do
better here and a direct error message for the case where
we can't find `/boot/loader` which is the majority of these.

The other case could happen if e.g. just the BLS fragment
for the booted deployment was deleted; let's reword that
one a bit too.

Closes: #1905
Approved by: rfairley

src/libostree/ostree-sysroot.c

index b3ad2498aeabe4a5fb4b7da9e15664cdd543f7a5..2c0c0546d29770ad002eec1d7b86b79b351b5e8e 100644 (file)
@@ -959,7 +959,18 @@ ostree_sysroot_load_if_changed (OstreeSysroot  *self,
     }
 
   if (self->root_is_ostree_booted && !self->booted_deployment)
-    return glnx_throw (error, "Unexpected state: /run/ostree-booted found and in / sysroot but not in a booted deployment");
+    {
+      if (!glnx_fstatat_allow_noent (self->sysroot_fd, "boot/loader", NULL, AT_SYMLINK_NOFOLLOW, error))
+        return FALSE;
+      if (errno == ENOENT)
+        {
+          return glnx_throw (error, "Unexpected state: /run/ostree-booted found, but no /boot/loader directory");
+        }
+      else
+        {
+          return glnx_throw (error, "Unexpected state: /run/ostree-booted found and in / sysroot, but bootloader entry not found");
+        }
+     }
 
   if (!_ostree_sysroot_reload_staged (self, error))
     return FALSE;